Optimization in Mechanical Engineering#
Description#
Using the optimization methods implemented in optymus: (a) determine the displacements \((u, v)\), of point A, that minimize the Total Potential Energy (\(\Pi\)) of the spring system indicated in the figure below. Adopt the following numerical values:
Initial points: \(x0 = \{15, 12\}^t\) e \(x0 = \{9, −2\}^t\);
\(L1 = 12 cm\);
\(L2 = 8\) cm;
\(EA1 = 12 N\) ;
\(EA2 = 80 N\) ;
\(\rho 1 = 0.82 N/cm\);
\(\rho 2 = 0.52 N/cm\);
We can see the system in the image below:

We can optimize the system by minimizing the total potential energy of the system, which is given by:
\[\Pi = \frac{1}{2} \left( EA1 \cdot \rho1 \cdot (L1 - \sqrt{u^2 + v^2})^2 + EA2 \cdot \rho2 \cdot (L2 - \sqrt{u^2 + v^2})^2 \right)\]
and numeically,
\[\Pi = 5(((x_1 - 8)^2 + x_2^2)^{1/2} - 8)^2 - 7x_2 + 0.5(((x_1 + 12)^2 + x_2^2)^{1/2} - 12)^2\]
Implementation#
[2]:
from optymus import Optimizer
import jax.numpy as jnp
[3]:
def f(x):
return 5 * (((x[0] - 8)**2 + x[1]**2)**0.5 - 8)**2 - 7 * x[1] + 0.5 * (((x[0] + 12)**2 + x[1]**2)**0.5 - 12)**2
[4]:
initial_point = jnp.array([9.0, -2.0])
opt = Optimizer(f_obj=f, x0=initial_point, method='gradient_descent')
Gradient Descent 0: 25%|██▌ | 25/100 [00:01<00:04, 18.14it/s]
[5]:
opt.print_report()
[5]:
| Method | Initial Guess | Optimal Solution | Objective Function Value | Number of Iterations | Time Elapsed | |
|---|---|---|---|---|---|---|
| Optimization Results | gradient_descent | [9.0, -2.0] | [2.785253744732174, 6.899690146261366] | -36.88042838981271 | 25 | 1.675446 |
[6]:
opt.plot_results(show=True, notebook=True, min=-20, max=20)